package com.zxyankh.raft.service.impl;

import com.zxyankh.raft.domain.LogEntryDomain;
import com.zxyankh.raft.repository.LogRepository;
import com.zxyankh.raft.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ankh
 * @since 31.10.2017
 */
@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogRepository logRepository;

    @Override
    public void addLogEntry(LogEntryDomain logEntryDomain) {
        logRepository.saveAndFlush(logEntryDomain);
    }

    @Override
    public LogEntryDomain findLogEntry(int term, int index, int server) {
        return logRepository.findLogEntry(term, index, server);
    }

    @Override
    public List<LogEntryDomain> findLogEntries(int server) {
        return logRepository.findLogEntries(server);
    }
}
